﻿using System;
using Light.Framework.Contract;
using Light.Framework.Component;
using Light.Utility;

namespace Light.Framework
{
    /// <summary>
    /// 服务器端处理中心
    /// </summary>
    public class ServerApplication
    {
        private static Logger _logger = null;
        private const string USER_COOKIE_ID = "light_framework_cookie_user_id";
        private const string USER_SESSION_ID = "light_framework_session_user_id_";

        private static WebCache _webCache = new WebCache();

        /// <summary>
        /// 当前登录用户IUser
        /// </summary>
        public static IUser User
        {
            get
            {
                return WebHelper.GetSession<IUser>(USER_SESSION_ID);
            }
            set
            {
                WebHelper.SetSession(USER_SESSION_ID, value);
            }
        }


        /// <summary>
        /// 日志管理器
        /// </summary>
        public static Logger Logger
        {
            get
            {
                if (_logger == null)
                    _logger = new Logger();
                return _logger;
            }
        }


        /// <summary>
        /// Web缓存
        /// </summary>
        public static WebCache Cache
        {
            get
            {
                return _webCache;
            }
        }
    }
}
